<?php
?>


      <link rel="stylesheet" type="text/css" href="index.css" />
      <style type="text/css">
	
	* { font-family: Verdana; font-size: 10pt; }
	
	label { width: 10em; float: right; }
	
	label.error { float: right; color: red; padding-left: .5em; vertical-align: top; }
	
	p { clear: both; }
	
	.submit { margin-left: 12em; }
	
	em { font-weight: bold; padding-right: 1em; vertical-align: top; }
	
	form { width: 40em; }




</style>
    <link rel="stylesheet" href="../miub/jquery-ui-1.8.16.custom/themes/base/jquery.ui.all.css">
    <link rel="stylesheet" href="../miub/jquery-ui-1.8.16.custom/css/ui-lightness/jquery-ui-1.8.16.custom.css">
	<script src="../miub/jquery-ui-1.8.16.custom/js/jquery-1.6.2.min.js"></script>
	<script src="../miub/jquery-ui-1.8.16.custom/js/jquery-ui-1.8.16.custom.min.js"></script>
	<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"></script>
	<script src="../miub/jquery-ui-1.8.16.custom/development-bundle/ui/jquery-ui-timepicker-addon.js"></script>
	<script src="../miub/jquery-ui-1.8.16.custom/development-bundle/ui/jquery-ui-sliderAccess.js"></script>
    <script src="../miub/jquery-ui-1.8.16.custom/js/jquery.validate.js"></script>
    <script src="../miub/jquery-ui-1.8.16.custom/js/jquery.ui.datepicker.validation.js"></script>



<!--  
<script>
    $(function() {
        $( "#datepicker" ).datepicker({
            changeMonth: true,
            changeYear: true,
            dateFormat:"yy-mm-dd"

        });
    });
    </script>-->

 <script>
 function LocalTimetoUTC(localTime)
 {

	 try{
		 var dateTimeComponents = localTime.split(" ");
		  var dateComponent = dateTimeComponents[0].split("-");
		  var timeComponent = dateTimeComponents[1].split(":");
	
	  var ampm = dateTimeComponents[2];

	  var dat = new Date(parseInt(dateComponent[0]),
	    parseInt(dateComponent[1]) -1,
	    parseInt(dateComponent[2]),
	    parseInt(timeComponent[0]) % 12,
	    parseInt(timeComponent[1]),
	    parseInt(timeComponent[2]) );
	 }catch(e){
			return 'Invalid Date';	
		}
	  if (ampm == "PM")  // do all locales use 'AM' / 'PM' ??
	  {
	    dat.setHours(dat.getHours() + 12);
	  }
	 
 return dat;
 }
  
  $(document).ready(function(){
	  
	
	  function countChecked() {
		  var n = $("input:checked").length-1;
		  $("#count").text("Waehlen Sie bitte mindestens ein Geraet aus(aktuell : "+n+")" );
		}
		countChecked();
		$(":checkbox").click(countChecked);
		
		/*$("#submit").click(function () {
			var str = $("#auswahl").serialize();
			var kundenauswahl = $("#a:checkbox:checked").val();
		      alert("'" + kundenauswahl + "'");

		      str = jQuery.validator.format(str, "World", "Bob");
		      alert("'" + str + "'");
		    });*/
		  

  });
  
  </script>
<script>
$(document).ready(function(){

$("#submit").click(function () {
    var str="";
    var k= $("#vonbis:checked").size();


   // {alert($("#vonbis:checked").size())};
    var n=$('.require-one:checked').size() ;

    var von= $("#von");
    var bis=$("#bis");
    if(n==0)str="Sie muessen mindestens ein Messgeraet auswaehlen\n";

if(k==1){
   
    if(von.val()=="")str+="Sie muessen Startzeit eingeben\n";
    if(bis.val()=="")str+="Sie muessen Endtzeit eingeben\n";
    if(bis.val()!="" && von.val()!=""){
   	 var x=LocalTimetoUTC(von.val());
	 var y=LocalTimetoUTC(bis.val());
	   // if(x=='Invalid Date')alert(x);
	    if(x==false || x=='Invalid Date' || y==false || y=='Invalid Date')
	    { str+="Sie haben Invalid Date eingegeben \n";
	    }
	    else{
	     x=x.getTime()/1000;
	    y=y.getTime()/1000;
if(x>y)str+="Startzeit bzw. Endzeit ist falsch \n";
if((y-x)>31700000)str+="Sie Koennen hoechstens 1 Jahr als Zeit-Intervall auswaehlen \n";
       
      //  x=x.toGMTString();
        //y=y.toGMTString();
        // gesamt=y-x;
       // str+=y+" minus "+x+" = "+(y-x);
	    }  
    }
}


if(str!=""){
    alert(str);
    return false;}else return true;




    /**
    if(k==1){
        $("#auswahl").validate({

            rules:{
                von: "required",
                bis: "required"

            },


            messages: {
                von: "Bitte startzeit eingeben" ,
                bis: "Bitte Endezeit eingeben"

            }
        }) ;
    }**/

});



});
</script>

<form id ="auswahl" action="tabelle.php" method="POST">
		<p align="center"><b>Bitte w&auml;hlen Sie das Messger&auml;t aus:</b><br></p>
		<fieldset  style="width: 881px;">
		<legend align="center" style="padding: 0 20px; ">Messger&auml;te</legend>
		<div id="count"></div>
			<u><i>Psychrometer</i></u><br>

			<input type="checkbox" name="trockentemperatur" value="tempTrockenAVG" class="require-one" >Temperatur<br>
			<input type="checkbox" name="feuchttemperatur" value="tempFeuchtAVG" class="require-one" >Feuchttemperatur<br>
			
			<u><i>Drucksensor</i></u><br>
			<input type="checkbox" name="druck" value="druck" class="require-one">Druck<br>

			
			<u><i>Regenmesser</i></u><br>
			<input type="checkbox" name="regen" value="regen" class="require-one">Regen<br>
			
			<u><i>Pluvio</i></u><br>
			<input type="checkbox" name="mengeNEZ" value="mengeNEZ" class="require-one">mengeNEZ<br>
			
			<u><i>Windmesser</i></u><br>

			<input type="checkbox" name="windrichtung" value="windrichtung" class="require-one">Windrichtung<br>
			<input type="checkbox" name="windgeschwendigkeit" value="windgeschwendigkeit" class="require-one">Windgeschwendigkeit<br>
			
			<u><i>BLS900A</i></u><br>

			<input type="checkbox" name="ct2" value="ct2" class="require-one">Schwankungen der Strukturfunktion der Temperatur(ct2)<br>
			<input type="checkbox" name="heatFluxFree" value="heatFluxFree" class="require-one">Heat Flux (Free Convection)<br>
            <input type="checkbox" name="crosswind" value="crosswind" class="require-one">crosswind<br>
            
            	<u><i>Strahlung2</i></u><br>

			<input type="checkbox" name="red-wt" value="red-wt" class="require-one">red AVG wt<br>
			<input type="checkbox" name="yellow-wt" value="yellow-wt" class="require-one">Yellow AVG watt<br>
            <input type="checkbox" name="soldir-wt" value="soldir-wt" class="require-one">Soldir AVG watt<br>
            <input type="checkbox" name="pir-wt" value="pir-wt" class="require-one">Pir AVG watt<br>
            <input type="checkbox" name="shad-wt" value="shad-wt" class="require-one">Shad AVG watt<br>
            
               	<u><i>Ceilometer2</i></u><br>

			<input type="checkbox" name="cloudlayer1" value="cloudlayer1" class="require-one">Cloud Layer1<br>
			<input type="checkbox" name="cloudlayer2" value="cloudlayer2" class="require-one">Cloud Layer2<br>
			<input type="checkbox" name="cloudlayer3" value="cloudlayer3" class="require-one">Cloud Layer3<br>
            <input type="checkbox" name="penetrationdepth1" value="penetrationdepth1" class="require-one">Penetration Depth 1<br>
            <input type="checkbox" name="penetrationdepth2" value="penetrationdepth2" class="require-one">Penetration Depth 2<br>
            <input type="checkbox" name="penetrationdepth3" value="penetrationdepth3" class="require-one">Penetration Depth 3<br>
		
		
		<input type="reset" value="Ger&auml;teeingabe l&ouml;schen">
		</fieldset>

		<p align="center"><b>Bitte machen Sie eine Vorauswahl welchen Zeitraum sie darstellen wollen:</b><br></p>
		<fieldset>
		<legend align="center" style="padding: 0 20px; ">Zeitraum</legend>
			<input id='vonbis' type="radio" name="zeitraum" value="vonbis" checked="checked" >Beliebige Zeit Interval:(yyyy-mm-dd hh:mm:ss)<br>
	

	<script>
       
	$(function() {
		var dates = $( "#von, #bis" ).datetimepicker({
	
			changeMonth: true,
			changeYear: true,
			dateFormat:'yy-mm-dd',
			minDate:new Date(1994,01,01),
			maxDate:new Date(),
			
			yearRange: 'c-100:c+100',
			numberOfMonths: 1,

			onSelect: function( selectedDate ) {
				var option = this.id == "von" ? "minDate" : "maxDate",
					instance = $( this ).data( "datepicker" ),
					date = $.datepicker.parseDate(
						instance.settings.dateFormat ||
						$.datepicker._defaults.dateFormat,
						selectedDate, instance.settings );
				dates.not( this ).datepicker( "option", option, date );
			},
			showSecond: true,
			timeFormat: 'hh:mm:ss',
			addSliderAccess: true,
			sliderAccessArgs: { touchonly: false },
            showOn: "button",
            buttonImage: "../miub/jquery-ui-1.8.16.custom/css/ui-lightness/images/calendar.gif",
            buttonImageOnly: true
			
			
			
		});

	});
	</script>

 

<div class="demo">
<br>
von
<input type="datetime" id="von" name="von" value=""   placeholder="Startzeit eingeben" />
bis
<input type="datetime" id="bis" name="bis"  value=""  placeholder="Endzeit eingeben" />

</div>
				<input type="radio" name="zeitraum" value="<?php echo date('Y-m-d H:i:s', strtotime('-1 day'));?> ">LETZTER TAG<br>
				<input type="radio" name="zeitraum" value="<?php echo date('Y-m-d H:i:s', strtotime('-1 week'));?>">LETZTE WOCHE<br>
				<input type="radio" name="zeitraum" value="<?php echo date('Y-m-d H:i:s', strtotime('-1 month'));?> ">LETZTER MONAT<br>
				<input type="radio" name="zeitraum" value="<?php echo date('Y-m-d H:i:s', strtotime('-4 month'));?>">LETZTES QUARTAL<br>
				<input type="radio" name="zeitraum" value="<?php echo date('Y-m-d H:i:s', strtotime('-12 month'));?>">LETZTES JAHR<br>


	
	
		</fieldset>

	<p align="center"><input id="submit" type="submit" value="abschicken"></p>
		


</form>
